package com.exchange.View;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.animation.Animation.AnimationListener;
import android.widget.ListView;
import com.exchange.Controller.ExchangeDataService;
import com.exchange.Controller.MoreClickListener;
import com.exchange.Controller.MoreFinishListener;
import com.exchange.Public.ExchangeConstants;
import com.exchange.Public.h;
import com.exchange.Public.k;
import com.exchange.Public.n;

public class ExchangeViewManager
{
  ag a = null;
  z b = null;
  j c = null;
  ae d = null;
  m e = null;
  Context f;
  int g;
  final Handler h;
  private ExchangeDataService i;

  public ExchangeViewManager()
  {
    this.h = new O(this);
    this.i = new ExchangeDataService();
  }

  public ExchangeViewManager(ExchangeDataService paramExchangeDataService)
  {
    this.h = new O(this);
    if (paramExchangeDataService == null)
      this.i = new ExchangeDataService();
    while (true)
    {
      return;
      this.i = paramExchangeDataService;
    }
  }

  public void addView(Context paramContext, ViewGroup paramViewGroup, int paramInt, String[] paramArrayOfString)
  {
    if (paramArrayOfString != null);
    try
    {
      if ((paramArrayOfString.length > 0) && (paramArrayOfString.length >= 1))
        ExchangeConstants.CHANNEL = paramArrayOfString[0];
      this.f = paramContext;
      if ((ExchangeConstants.ONLY_CHINESE) && (!(h.a(this.f))))
      {
        n.b(ExchangeConstants.LOG_TAG, "English os can not show ads");
      }
      else
      {
        this.g = paramInt;
        if (this.g == 7)
          new x(paramContext, null).show();
      }
    }
    catch (Exception localException)
    {
      n.b(ExchangeConstants.LOG_TAG, "add view error" + localException.getMessage());
      return;
      if ((!(h.d(paramContext))) && (ExchangeConstants.USE_SCROLL_VIEW_LANDSCAPE))
        this.g = 10;
      switch (this.g)
      {
      default:
        n.b(ExchangeConstants.LOG_TAG, "paramter type cannot be handled");
        break;
      case 0:
      case 1:
        this.b = new z(paramContext, paramViewGroup, this.g, this.i);
        break;
      case 4:
      case 5:
        this.a = new ag(paramContext, paramViewGroup, this.g, this.i);
        break;
      case 6:
        this.c = new j(paramContext, paramViewGroup, this.g, this.i);
        break;
      case 10:
        this.d = new ae(paramContext, paramViewGroup, this.g, this.i);
        break;
      case 41:
      case 42:
        this.e = new m(paramContext, paramViewGroup, this.g, this.i);
      }
    }
  }

  public void addView(Context paramContext, ViewGroup paramViewGroup, ListView paramListView)
  {
    new EmbededContainer(paramContext, paramViewGroup, paramListView, this.i);
  }

  public void hideBanner()
  {
    try
    {
      switch (this.g)
      {
      default:
        n.b(ExchangeConstants.LOG_TAG, "paramter type cannot be handled");
        break;
      case 0:
      case 1:
        if (this.b != null)
          this.b.h.setVisibility(8);
      case 4:
      case 5:
      case 41:
      case 42:
      case 6:
      case 10:
      }
    }
    catch (Exception localException)
    {
      n.b(ExchangeConstants.LOG_TAG, "hideBanner error");
      return;
      if (this.a != null)
      {
        k.b(this.f, this.a.j);
        return;
        if (this.e != null)
        {
          k.b(this.f, this.e.i);
          return;
          if (this.c != null)
          {
            k.a(this.c.c);
            return;
            if (this.d != null)
              k.a(this.d.k);
          }
        }
      }
    }
  }

  public void hideBanner(int paramInt)
  {
    new P(this, paramInt).run();
  }

  public boolean isFling()
  {
    try
    {
      switch (this.g)
      {
      case 0:
      case 1:
        if (this.b == null)
        {
          bool1 = false;
          break label194:
        }
        bool1 = this.b.h.a();
        break;
      case 4:
      case 5:
        if (this.a == null)
        {
          bool1 = false;
          break label194:
        }
        bool1 = this.a.j.a();
        break;
      case 41:
      case 42:
        if (this.e == null)
        {
          bool1 = false;
          break label194:
        }
        bool1 = this.e.i.a();
        break;
      case 10:
        if (this.d == null)
        {
          bool1 = false;
          break label194:
        }
        boolean bool2 = this.d.k.a();
        bool1 = bool2;
      }
    }
    catch (Exception localException)
    {
      n.b(ExchangeConstants.LOG_TAG, "isFling error");
      bool1 = false;
    }
    boolean bool1 = false;
    label194: return bool1;
  }

  public boolean isOpen()
  {
    try
    {
      switch (this.g)
      {
      case 0:
      case 1:
        if (this.b == null)
        {
          bool1 = false;
          break label194:
        }
        bool1 = this.b.h.d();
        break;
      case 4:
      case 5:
        if (this.a == null)
        {
          bool1 = false;
          break label194:
        }
        bool1 = this.a.j.d();
        break;
      case 41:
      case 42:
        if (this.e == null)
        {
          bool1 = false;
          break label194:
        }
        bool1 = this.e.i.d();
        break;
      case 10:
        if (this.d == null)
        {
          bool1 = false;
          break label194:
        }
        boolean bool2 = this.d.k.d();
        bool1 = bool2;
      }
    }
    catch (Exception localException)
    {
      n.b(ExchangeConstants.LOG_TAG, "isOpen error");
      bool1 = false;
    }
    boolean bool1 = false;
    label194: return bool1;
  }

  public void setAnimationListener(Animation.AnimationListener paramAnimationListener)
  {
    try
    {
      switch (this.g)
      {
      case 4:
      case 5:
        if (this.a != null)
          this.a.n = paramAnimationListener;
      }
    }
    catch (Exception localException)
    {
      n.b(ExchangeConstants.LOG_TAG, "set animationlistener error");
    }
  }

  public void setBannerOnClickListener(View.OnClickListener paramOnClickListener)
  {
    if (this.c != null)
      this.c.a(paramOnClickListener);
  }

  public void setHandlerDrawable(Drawable paramDrawable)
  {
    try
    {
      switch (this.g)
      {
      case 4:
      case 5:
        if (this.a != null)
          this.a.a(paramDrawable);
      }
    }
    catch (Exception localException)
    {
      n.b(ExchangeConstants.LOG_TAG, "set animationlistener error");
    }
  }

  public void setMoreClickListener(MoreClickListener paramMoreClickListener)
  {
    try
    {
      switch (this.g)
      {
      case 4:
      case 5:
        if (this.a != null)
          this.a.m = paramMoreClickListener;
      }
    }
    catch (Exception localException)
    {
      n.b(ExchangeConstants.LOG_TAG, "set more click listener error");
    }
  }

  public void setMoreFinishListener(MoreFinishListener paramMoreFinishListener)
  {
    try
    {
      switch (this.g)
      {
      case 4:
      case 5:
        if (this.a != null)
          x.a = paramMoreFinishListener;
      }
    }
    catch (Exception localException)
    {
      n.b(ExchangeConstants.LOG_TAG, "set more finish listener error");
    }
  }

  public void showBanner()
  {
    try
    {
      switch (this.g)
      {
      default:
        n.b(ExchangeConstants.LOG_TAG, "paramter type cannot be handled");
        break;
      case 0:
      case 1:
        if (this.b != null)
          this.b.h.setVisibility(0);
      case 4:
      case 5:
      case 41:
      case 42:
      case 6:
      case 10:
      }
    }
    catch (Exception localException)
    {
      n.b(ExchangeConstants.LOG_TAG, "showBanner error");
      return;
      if (this.a != null)
      {
        k.a(this.f, this.a.j);
        return;
        if (this.e != null)
        {
          k.a(this.f, this.e.i);
          return;
          if (this.c != null)
          {
            k.b(this.c.c);
            return;
            if (this.d != null)
              k.a(this.f, this.d.k);
          }
        }
      }
    }
  }

  public void toggle()
  {
    while (true)
    {
      while (true)
      {
        while (true)
        {
          try
          {
            switch (this.g)
            {
            default:
              n.b(ExchangeConstants.LOG_TAG, "paramter type cannot be handled");
              break;
            case 0:
            case 1:
              if (this.b.h.d())
              {
                bool4 = false;
                if (this.b == null)
                  break label258;
                this.b.h.a(bool4, true);
              }
            case 4:
            case 5:
            case 41:
            case 42:
            case 10:
            }
          }
          catch (Exception localException)
          {
            while (true)
            {
              n.b(ExchangeConstants.LOG_TAG, "toggle error");
              break label258:
              boolean bool4 = true;
            }
            if (this.a == null)
              break label258;
            if (!(this.a.j.d()))
              break label259;
            bool3 = false;
            this.a.j.a(bool3, true);
            break label258:
            if (this.e == null)
              break label258;
            if (!(this.e.i.d()))
              break label265;
            bool2 = false;
            this.e.i.a(bool2, true);
            break label258:
            if (this.d == null)
              break label258;
            if (!(this.d.k.d()))
              break label253;
            bool1 = false;
            this.d.k.a(bool1, true);
          }
          break;
          label253: boolean bool1 = true;
        }
        label258: return;
        label259: boolean bool3 = true;
      }
      label265: boolean bool2 = true;
    }
  }
}